<template>
	<div>
		<el-form ref="form" :rules="rules" :model="form" label-width="120px">


			<el-form-item label="姓名" prop="name">
				<el-input v-model="form.name"></el-input>
			</el-form-item>
			<el-form-item label="性别" prop="sex">
				
				
				 <el-select v-model="form.sex" placeholder="请选择">
				    <el-option
				      v-for="item in options"
				      :key="item.value"
				      :label="item.label"
				      :value="item.label">
					<!-- <el-input v-model="form.status"></el-input> -->
					  
				    </el-option>
				  </el-select>
			</el-form-item>
			</el-form-item>
				<el-form-item label="出生日期" prop="birth">
					<span class="demonstration"></span>
					    <el-date-picker
					      v-model="form.birth "
					      type="date"
						  value-format="yyyy-MM-dd"
					      placeholder="选择日期">时间
					    </el-date-picker>
					
				</el-form-item>
			</el-form-item>

			<el-form-item label="身高" prop="high">
				<el-input v-model="form.high"></el-input>
			</el-form-item>
			<el-form-item label="婚姻状况" prop="marry">
				
				
				 <el-select v-model="form.marry" placeholder="请选择">
				    <el-option
				      v-for="item in options1"
				      :key="item.value"
				      :label="item.label"
				      :value="item.label">
					<!-- <el-input v-model="form.status"></el-input> -->
					  
				    </el-option>
				  </el-select>
			</el-form-item>
			<el-form-item label="体重" prop="weight">
				<el-input v-model="form.weight"></el-input>
			</el-form-item>
			<el-form-item label="血型" prop="blood">
				<el-input v-model="form.blood"></el-input>
			</el-form-item>
			
			<el-form-item label="慢性病" prop="chronicDisease">
				<el-input v-model="form.chronicDisease"></el-input>
			</el-form-item>
			
			<el-form-item label="家族病史" prop="familyHistory">
				<el-input v-model="form.familyHistory"></el-input>
			</el-form-item>
			
			

			<el-form-item>
				<el-button type="primary" plain @click="save">保存数据</el-button>

			</el-form-item>
		</el-form>
	</div>
</template>

<script>
	export default {
		name: 'health_records',
		components: {

		},
		props: [
			'show',
			'editid'
		],
		data() {
			return {
				form: {
					name: '',
					sex: '',
					age: '',
					birth: '',
					high: '',
					marry: '',
				},
				options: [{
				        value: '选项1',
				        label: '男'
				      }, {
				        value: '选项2',
				        label: '女'
				      }], 
				options1: [{
				        value: '选项1',
				        label: '已婚'
				      }, {
				        value: '选项2',
				        label: '未婚'
				      }, {
				        value: '选项3',
				        label: '离异'
				      }], 	  
				rules: {

					name: [{
							required: true,
							message: '类别名不能为空',
							trigger: 'blur'
						},
						{
							min: 1,
							max: 100,
							message: '长度在 1 到 100 个字符',
							trigger: 'blur'
						}
					]
				},

				health_records: [],
				depts: [],
			}
		},
		created() {
			if (this.editid) {
				this.show = true;
				this.$axios.get(
					'healthRecords/getById',
					response => {
						this.form = response.obj
					}, 
					{id: this.editid })
			}
		},
		methods: {
			save() {
				this.axios.get('/healthRecords/add', (data) => {
					if (data) {
						this.$emit('update:show', false)
						this.$emit('getData')
					}

				}, this.form, '保存成功');
			},
			update(){
				this.axios.get('/healthRecords/update', (data) => {
					if (data) {
						this.$emit('update:show', false)
						this.$emit('getData')
					}
				
				}, this.id,this.status,'更新成功');
		}



	},
}
</script>

<style>
</style>